<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>GitHub Issue 1439</title>
    <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
    <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
    <script src="../../../dist/jsoneditor.js"></script>
  </head>
  <body>
    <div class="container">
      <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
      <a href="https://github.com/json-editor/json-editor/issues/1439">GitHub Issue 1439</a>
      <div id='editor_holder'></div>
    </div>

    <script>
      var value = document.querySelector('#value')
      var defaultSchema = {
        "type": "object",
        "properties": {
          "wrong": {
            "type": "button",
            "title": "Search",
            "options": {
              "button": {
                "icon": "search",
                "action": "myAction",
                "validated": true
              }
            }
          },
          "correct": {
            "format": "button",
            "options": {
              "button": {
                "text": "Button text",
                "icon": "search",
                "action": "myAction",
                "validated": true
              }
            }
          }
        }
      }

      JSONEditor.defaults.callbacks = {
        "button" : {
          "myAction" : function () {
            alert('Button action')
          }
        }
      }

      var editor = new JSONEditor(document.getElementById('editor_holder'), {
        iconlib: 'fontawesome5',
        schema: defaultSchema,
        show_errors: 'always',
        theme: 'bootstrap4'
      })

      editor.on('change', function () {
        value.value = JSON.stringify(editor.getValue())
      })
    </script>
  </body>
</html>
